
Compl = {};
Compl.__index = Compl;

function Compl.init(id)
    local self = {};
    self.ComplItems = {};
    self.out = io.tmpfile();
    local out = self.out;
    out:write('{','"jsonrpc":"2.0","id":',id,',"result":{"isIncomplete":false,"items":[');

    function self._end()
        out:write(']}}');
    end
    setmetatable(self,Compl);
    return self;
end

function Compl:AddItem(t)
    if(#self.ComplItems>0)then
        self.out:write(',');
        toJsonFile(t,nil,self.out);
    else
        toJsonFile(t,nil,self.out);
    end
    table.insert(self.ComplItems,t);
end

function Compl:End()
    self:_end();
    RPC_writeOut(self.out);
    self.out:close();
    setmetatable(self, nil);
end

